﻿using Microsoft.EntityFrameworkCore;


namespace EntityModels.DbContexts
{
    /// <summary>
    /// 索引器属性、共享类型实体和属性包
    /// </summary>
    public class SharedTypePropertyPackageContext : DbContext
    {
        public DbSet<Dictionary<string, object>> Entities1 => Set<Dictionary<string, object>>("Entities1");
        public DbSet<Dictionary<string, object>> Entities2 => Set<Dictionary<string, object>>("Entities2");

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.SharedTypeEntity<Dictionary<string, object>>("Entities1", b =>
            {
                b.IndexerProperty<int>("Id");
                b.IndexerProperty<string>("Text").IsRequired();
            });

            modelBuilder.SharedTypeEntity<Dictionary<string, object>>("Entities2", b =>
            {
                b.IndexerProperty<int>("Id");
                b.IndexerProperty<double?>("Number");
            });
        }

    }
}
